package com.xgry.bpm.api.business.postfiles.service.impl;

import com.xgry.bpm.api.business.postfiles.entity.PostFiles;
import com.xgry.bpm.api.business.postfiles.mapper.PostFilesMapper;
import com.xgry.bpm.api.business.postfiles.service.PostFilesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.apache.http.HttpStatus;

import java.util.List;

/**
* <p>
    * PostFiles服务实现类
    * </p>
*
* @author adrian
* @since 2020-07-08
*/
@Service
public class PostFilesServiceImpl extends ServiceImpl<PostFilesMapper, PostFiles>implements PostFilesService {

    @Override
    public int deleteById(String id){
        if(StringUtils.isEmpty(id)){
            throw new IllegalArgumentException(String.valueOf(HttpStatus.SC_METHOD_FAILURE));
        }
        return baseMapper.deleteById(id);
    }

    @Override
    public PostFiles selectById(String id){
        if(StringUtils.isEmpty(id)){
            throw new IllegalArgumentException(String.valueOf(HttpStatus.SC_METHOD_FAILURE));
        }
        PostFiles data=baseMapper.selectById(id);
        return data;
    }

    @Override
    public List<PostFiles>selectAll(PostFiles record){
        QueryWrapper<PostFiles>queryWrapper=new QueryWrapper<>();
        queryWrapper.setEntity(record);
        List<PostFiles>list=baseMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public IPage<PostFiles>selectPage(IPage<PostFiles> page , PostFiles record){
        // 查询条件
        QueryWrapper<PostFiles>queryWrapper=new QueryWrapper<>();
        queryWrapper.setEntity(record);
        return baseMapper.selectPage(page,queryWrapper);
    }

    @Override
    public IPage<PostFiles>getPage(IPage<PostFiles>page,QueryWrapper<PostFiles>queryWrapper){
        return baseMapper.selectPage(page,queryWrapper);
    }
}